<?php
class SiteMapForm extends Form
{
    function __construct()
	{
        $this->link_css('style/aznet/jquery.treeview.css');
        $this->link_js('javascript/jquery/jquery.treeview.js');
        $this->link_js('javascript/jquery/jquery.highlight-3.js');
		
        Form::Form('SiteMapForm');
    }

    function draw() {
        global $display;
        $site_map = array();
        foreach (CGlobal::$allZones as $zone) {
            if (is_array($zone['cats'])) {
                $cat_lv1 = array();
                foreach ($zone['cats'] as $catLv1Key => $catLv1Val) {
                    if (isset(CGlobal::$allCategories[$catLv1Val])) {
                        $catlv1 = CGlobal::$allCategories[$catLv1Val];
                        if (isset(CGlobal::$subCategories[$catlv1['id']])) {
                            $catslv2 = CGlobal::$subCategories[$catlv1['id']];
                            foreach($catslv2 as $catlv2)
                            {
                                $catlv2['url'] = WEB_DIR."c{$catlv2['id']}/{$catlv1['ebname']}-{$catlv2['ebname']}";
                                $catlv1['childs'][$catlv2['id']] = $catlv2;
                            }
                            
                            
                        }
                        $catlv1['url'] = WEB_DIR . "c{$catlv1['id']}/{$catlv1['ebname']}";
                        $cat_lv1[$catLv1Val] = $catlv1;
                    }
                }
                $zone['cats'] = $cat_lv1;
            }
            $site_map[$zone['id']] = $zone;
        }

        $display->add('site_map', $site_map);
        $display->output("SiteMap");
        $this->endForm();
    }

}

?>